#!/bin/bash

if [[ "$1" == "" ]]; then
    printf "Unset Photivo repo."
    unset PhotivoRepoPath
    unset PhotivoBuildPath
    export PhotivoRepoId=none

else
    if [[ "$1" == "def" ]]; then
        ptTempPath=$ProjectsBasePath/Photivo/$RepoDefaultDir
    else
        if [[ -e $ProjectsBasePath/Photivo/branch-$1 ]]; then
            ptTempPath=$ProjectsBasePath/Photivo/branch-$1
        else
            ptTempPath=$ProjectsBasePath/Photivo/$1
        fi
    fi

    if [[ ! -e $ptTempPath ]]; then
        echo "Folder \"$ptTempPath\" does not exist."
    else
        export PhotivoRepoPath=$ptTempPath
        export PhotivoBuildPath=$ptTempPath/build-$GccArch
        export PhotivoRepoId=$1
        printf "\n\$PhotivoRepoPath  is now \"$PhotivoRepoPath\"\n"
        printf   "\$PhotivoBuildPath is now \"$PhotivoBuildPath\"\n"
        unset ptTempPath
        mkdir -p $PhotivoBuildPath
    fi
fi